/*
 * Copyright 2010 Biz-e (info@biz-e.nl)
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package nl.biz_e.site.client.editor;

import nl.biz_e.gwtappengine.lib.client.BaseAppEngineAppPanel;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ChangeEvent;
import com.google.gwt.event.dom.client.ChangeHandler;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.Grid;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Widget;

/**
 * Base panel for all editor panels.<br/>
 * Provides some sort of default layout and handlers for buttons and/or
 * listboxes.
 * 
 * @author Joost A. Bloemsma
 */
public abstract class EditorPanelBase extends BaseAppEngineAppPanel implements
		ChangeHandler, ClickHandler {
	/**
	 * Reference to I18N-ed strings
	 */
	protected final EditorStrings strings;
	private final Grid grid;
	
	/**
	 * Constructs a new EditorPanelBase instance
	 */
	public EditorPanelBase() {
		super();
		strings = (EditorStrings) GWT.create(EditorStrings.class);
		grid = new Grid(1, 3);
		grid.setWidth("100%");
		Label l1 = new Label("");
		l1.setWidth("150px");
		Label l2 = new Label("");
		l2.setWidth("150px");
		grid.setWidget(0, 0, l1);
		grid.setWidget(0, 2, l2);
		super.add(grid);
	}
	
	/**
	 * {@inheritDoc}
	 */
	@Override
	public void onChange(ChangeEvent event) {/* Override when needed */
	}
	
	/**
	 * {@inheritDoc}
	 */
	@Override
	public void onClick(ClickEvent event) {/* Override when needed */
	}
	
	/**
	 * {@inheritDoc}
	 */
	@Override
	public void add(Widget w) {
		this.grid.setWidget(0, 1, w);
	}
	
}
